home *** CD-ROM | disk | FTP | other *** search
/ Enter 2010 January / ENTER_2010_01.iso / Programy / Gry / Base_Invaders_ / BaseInvadersSetup1.3.exe / {app} / Scripts / Campaign10Startup.lua < prev    next >
Encoding:
Text File  |  2007-01-25  |  9.1 KB  |  369 lines

  1.  
  2. NuclearMissileID = 0
  3. FinalCinematic = false
  4.  
  5. -- Final, nuclear explosion cinematic
  6. function NuclearCinematic()
  7.  
  8.     FinalCinematic = true
  9.  
  10.     Camera.CinemaMove( Vector3(90,25,90), Vector3(146,8,150), 2 );
  11.  
  12.     local CinemaInvader  = G.CreateAt( "Basic", Vector3( 125, 0, 130 ) );
  13.     CinemaInvader.SetPosition( Vector3( 110, 20, 115 ) );
  14.     CinemaInvader.TurnOffAI();
  15.  
  16.     Cursor.SetPosition( Vector3( 115, 25, 110 ) )
  17.     Cursor.SetDirection( Vector3( 1,0,1 )  )
  18.     GameWait(2)
  19.  
  20.     -- Move the hand
  21.     G.SayPhraseScript( "It's ready!", CinemaInvader );
  22.     CinemaInvader.Hop( 20 )
  23.     TraitorTalk( "The nuclear missile is finally ready, Starting Countdown!" );
  24.     GameWait(4)
  25.  
  26.     LargeTextColor = Color(0.8,0.2,0.2,1)
  27.     LargeTextPopup( "5" );
  28.     GameWait(1)
  29.  
  30.     G.SayPhraseScript( "Finally!", CinemaInvader );
  31.     CinemaInvader.Hop( 20 )
  32.     TraitorTalk( "Finally the invader threat will be eliminated!" );
  33.     LargeTextPopup( "4" );
  34.     GameWait(1)
  35.     LargeTextPopup( "3" );
  36.     GameWait(1)
  37.     LargeTextPopup( "2" );
  38.     GameWait(1)
  39.     LargeTextPopup( "1" );
  40.     GameWait(1)
  41.     
  42.     local NuclearMissile = G.AccessCog( NuclearMissileID )
  43.     NuclearMissile.SetBehavior( "Missile" );
  44.     local nukePos = NuclearMissile.GetPosition()
  45.     local activateInv = G.CreateAt( "Ninja", nukePos + Vector3(4,0,0) )
  46.     activateInv.TurnOffAI()
  47.  
  48.     -- Zoom  to a hill where traitor & the hand is watching
  49.     GameWait(6)
  50.  
  51.     -- Watch the missile blows up tower (Don't fail mission)
  52.     TraitorTalk( "Oops, guess I should have positioned it better." );
  53.     G.SayPhraseScript( "Oops..." , CinemaInvader );
  54.     GameWait(5)
  55.     
  56.     CinemaInvader.SetDirection( Vector3(1,0,-1) )
  57.     TraitorTalk( "Great working with you, I'll See you next time!" );
  58.     G.SayPhraseScript( "Bye!" , CinemaInvader );
  59.     GameWait(5)
  60.     
  61.     CinemaInvader.Hop( 20 )
  62.     GameWait(0.25)
  63.     
  64.     -- Traitor tries to run away, hand grabs him
  65.     CinemaInvader.SetDirection( Vector3(-1,0,1) )
  66.     GameWait(0.25)
  67.     CinemaInvader.SetVelocity( Vector3(-1,0,1) * 20 )
  68.     GameWait(0.25)
  69.     
  70.     
  71.     
  72.     
  73.     local moveDir = CinemaInvader.GetPosition() - Cursor.GetPosition();
  74.     moveDir[1] = 0;
  75.     Cursor.SetDirection( moveDir )
  76.     Cursor.SetVelocity( moveDir * 1.25)
  77.  
  78.     -- Grab when over traitor
  79.     GameWait(1)
  80.     CinemaInvader.SetVelocity( Vector3(0,0,0) );
  81.     Cursor.SetVelocity( Vector3(0,0,0) );
  82.  
  83.     local cinPos = CinemaInvader.GetPosition()
  84.     Cursor.SetPosition( cinPos )
  85.     Cursor.SetGrabMode( true )
  86.     
  87.     FadeOut(1);
  88.     GameWait(1)
  89.  
  90.     Cursor.SetGrabMode( false )
  91.     
  92.     -- fade to black
  93. end
  94.  
  95.  
  96. --Common Level Start Code
  97. function LevelStartup()
  98.  
  99.     G.Create( "MenuData/HudCog.xml" );
  100.     G.Create( "Data/GameCamera.xml" );
  101.     G.Create( "Data/CursorCog.xml" );
  102.  
  103.     MainLevel = G.Create( "Data/Levels/Campaign10.xml" );
  104.     MainLevel.CreateLevel();
  105.  
  106.     local tempPos = Tower.GetPosition()
  107.     Camera.LookAtPosition( tempPos )
  108.     
  109.     local NuclearMissile = G.CreateAt( "missile", tempPos + Vector3( 0,0,20 ) );
  110.     NuclearMissile.SetBehavior( "None" ); --"Missile" )
  111.     NuclearMissileID =  NuclearMissile.GetID()
  112.     
  113.     G.SetInvSpeed( 20 );
  114.     HUD.EnterLevel();
  115.     G.SetGameState( InLevel );
  116.     G.SetPoints( 5 );
  117.     
  118.     G.SetLightTime( 0 );
  119.     G.PostP( "None" );
  120.     --TraitorTalk(" ");
  121.  
  122.     -- gameStartTime = 10000000;
  123.  
  124.     HUD.Message( "VictoryCondition" , "SetText", "Survive until the Missile Activates!"  );
  125.     HUD.Message( "LossCondition" , "SetText", "If the Tower or Missile falls you lose." );
  126.     
  127.     G.Create( "Data/SnowCell.xml" );
  128.     
  129.     TraitorCanBeHidden = true
  130.     
  131.     
  132. end
  133.  
  134. LevelStartup()
  135.  
  136. function LevelIntro()
  137.     
  138.     local tempPos = Tower.GetPosition()
  139.     Camera.LookAtPosition( tempPos )
  140.  
  141.     gameStartTime = GameTime;
  142.  
  143.     ColorTextPopup( "Level 10: Nuclear Winter", Color(1,1,1,1) )
  144.  
  145.     G.DisableTrapAll()
  146.         
  147.     G.EnableTrap("wall");
  148.     G.EnableTrap("bomb");
  149.     G.EnableTrap("hammer");
  150.     G.EnableTrap("fan");
  151.     G.EnableTrap("spring");
  152.     G.EnableTrap("zapper");
  153.     G.EnableTrap("vortex");
  154.     G.EnableTrap("axe");
  155.     G.EnableTrap("poison");
  156.     G.EnableTrap("flame");
  157.     G.EnableTrap("bulb");
  158.     G.EnableTrap("laser");
  159.     G.EnableTrap("satellite");
  160.  
  161.     DisableTraitor()
  162.     GameWait(1.5)
  163.  
  164.     G.EarnPoints( 250 );            
  165.     
  166. --    StartCinematic()
  167. --        NuclearCinematic();
  168. --    EndCinematic()
  169.  
  170. --    G.SetGameState( Victory );
  171. end
  172.  
  173. function LevelSequence()
  174.     
  175.     -- Layout:
  176.     -- ---------------------
  177.     -- |  Tower || Missile |
  178.     -- |        ||         |
  179.     -- ---------------------
  180.     --  More open with Fewer/weaker traps
  181.     
  182.     -- Intro
  183.     TraitorTalk("It's taken days but I think I've got it now.");
  184.     GameWait(4)
  185.     TraitorTalk("That big dome next to the tower hides a missile silo.");
  186.     GameWait(4)    
  187.     TraitorTalk("With this new nuclear missile trap we'll finally be able to defeat the invaders.");
  188.     GameWait(7)
  189.     TraitorTalk("But I still need 10 minutes before it'll be operational!");
  190.     GameWait(6)    
  191.     
  192.     -- Phase 1: Exploding Ninjas (Spiker/Kamikaze/Ninja) Intense stuff to weed out beginners, large spawn radius
  193.     ToughGuys = createSpawnStruct()
  194.     ToughGuys.Prob.Spiker    = 1.5
  195.     ToughGuys.Prob.Kamikaze    = 1.0
  196.     ToughGuys.Prob.Ninja    = 2.0
  197.     
  198.     ToughGuys.SpawnSpeed    = 1.0;
  199.     ToughGuys.MaxSpawn        = 15;
  200.     ToughGuys.TotalSpawn    = 100;
  201.     ToughGuys.GroupPercent    = 0.01;
  202.     ToughGuys.GroupSize        = 2;
  203.     ToughGuys.WhereToSpawn    = CircleAroundTower    
  204.  
  205.     AddWave( "ToughGuys", ToughGuys )
  206.     
  207.     GameWait( 120 )
  208.     StopWave( "ToughGuys" )
  209.     
  210.     TraitorTalk("8 minutes before the missile activates.");
  211.     
  212.     GameWait( 15 )
  213.     
  214.     -- Phase 2: Stacker Strike (Basic/Stacker/Squad) Weaker wave, just tons of guys in close
  215.     StackerWave = createSpawnStruct()
  216.     StackerWave.Prob.Basic        = 1.5
  217.     StackerWave.Prob.Squad        = 1.0
  218.     StackerWave.Prob.Stacker    = 2.0
  219.     
  220.     StackerWave.SpawnSpeed        = 2.0;
  221.     StackerWave.MaxSpawn        = 50;
  222.     StackerWave.TotalSpawn        = 250;
  223.     StackerWave.GroupPercent    = 0.15;
  224.     StackerWave.GroupSize        = 3;
  225.     StackerWave.WhereToSpawn    = SmallCircleAroundTower    
  226.  
  227.     AddWave( "StackerWave", StackerWave )
  228.     
  229.     GameWait( 120 )
  230.     StopWave( "StackerWave" )
  231.  
  232.     TraitorTalk("6 minutes before the missile activates.");
  233.  
  234.     GameWait( 15 )
  235.     
  236.     -- Phase 3: Big Guys w/ Power Tools (Psychic/Driller/Miner/Bomber) Medium Wave, Bomber/Psychic close, miner/driller far
  237.     BigGuys = createSpawnStruct()
  238.     BigGuys.Prob.Psychic    = 1.5
  239.     BigGuys.Prob.Bomber        = 1.0
  240.     
  241.     BigGuys.SpawnSpeed        = 1.0;
  242.     BigGuys.MaxSpawn        = 50;
  243.     BigGuys.TotalSpawn        = 200;
  244.     BigGuys.GroupPercent    = 0.01;
  245.     BigGuys.GroupSize        = 2;
  246.     BigGuys.WhereToSpawn    = SmallCircleAroundTower        
  247.     
  248.     PowerTools = createSpawnStruct()
  249.     PowerTools.Prob.Driller        = 1.0
  250.     PowerTools.Prob.Miner        = 1.5
  251.     
  252.     PowerTools.SpawnSpeed        = 1.0;
  253.     PowerTools.MaxSpawn            = 50;
  254.     PowerTools.TotalSpawn        = 200;
  255.     PowerTools.GroupPercent        = 0.15;
  256.     PowerTools.GroupSize        = 3;
  257.     PowerTools.WhereToSpawn        = CircleAroundTower    
  258.     
  259.     AddWave( "BigGuys", BigGuys )
  260.     AddWave( "PowerTools", PowerTools )
  261. --     G.SetMaxKills( 250 )
  262.     
  263.     GameWait( 120 )
  264.     StopWave( "BigGuys" )
  265.     StopWave( "PowerTools" )
  266.  
  267.     TraitorTalk("Less than 4 minutes before the missile activates.");
  268.  
  269.     GameWait( 15 )
  270.  
  271.     TraitorTalk("They're attacking all-out now!");
  272.     GameWait( 5 )
  273.     
  274.     -- Phase 4: Kitchen Sink (All) Emphasis on harder invaders, (some) random spawn location
  275.     BigGuys.MaxSpawn            = 50;
  276.     BigGuys.TotalSpawn            = 1000;
  277.     
  278.     PowerTools.MaxSpawn            = 50;
  279.     PowerTools.TotalSpawn        = 1000;
  280.  
  281.     StackerWave.MaxSpawn        = 50;
  282.     StackerWave.TotalSpawn        = 1000;
  283.     StackerWave.WhereToSpawn    = RandomAnywhere
  284.  
  285.     ToughGuys.MaxSpawn            = 50;
  286.     ToughGuys.TotalSpawn        = 1000;
  287.  
  288.     AddWave( "BigGuys", BigGuys )
  289.     AddWave( "PowerTools", PowerTools )
  290.     AddWave( "StackerWave", StackerWave )
  291.     AddWave( "ToughGuys", ToughGuys )    
  292.  
  293.     GameWait( 120 )
  294.  
  295.     -- Get rid of the easy guys
  296.  
  297.     TraitorTalk("Only 1 minute left.");
  298.  
  299.     StopWave( "StackerWave" )
  300.  
  301.     GameWait( 30 )
  302.  
  303.     -- Just Kamikazes for the end (cinematic will spawn more guys)
  304.     EndAllWaves()
  305.     
  306.     ToughGuys.Prob.Spiker    = 0
  307.     ToughGuys.Prob.Kamikaze    = 1.0
  308.     ToughGuys.Prob.Ninja    = 0
  309.     AddWave( "ToughGuys", ToughGuys )
  310.     
  311.     TraitorTalk("30 seconds left.");
  312.     
  313.     GameWait( 30 )
  314.     
  315.     EndAllWaves()
  316.     
  317.     -- Pause all invaders?
  318.     G.KillAllInvaders();
  319.     
  320.     -- End Cinematic:
  321.     TrapTextPopup("Missile")
  322.     
  323.     StartCinematic()
  324.         NuclearCinematic();
  325.     EndCinematic()
  326.  
  327.     G.SetGameState( Victory );
  328.     
  329. end
  330.  
  331. -- Check that the missile is not active either.
  332. function CheckLevelCompletion( )
  333.  
  334.     -- local tower = G.GetCogName("Tower");
  335.     -- G.Mes( tostring( NuclearMissileID ) )
  336.     local NuclearMissile = G.AccessCog( NuclearMissileID )
  337.     
  338.     if( (( Tower == nil or not Tower.IsValid() )or
  339.          (NuclearMissile == nil or not NuclearMissile.IsValid()) ) and not FinalCinematic ) then
  340.         G.SetGameState( Defeat );    
  341.     end
  342.     
  343.     if( not( GameState == InLevel ) ) then
  344.         dofile( "Scripts/GameOver.lua" );        -- The gameover script should do all exit functionality:
  345.         GMain["LevelUpdate"] = nil;
  346.     end        
  347. end
  348.  
  349. function LevelUpdate()
  350.     
  351.     -- Make sure the player isn't trying to exit the level
  352.     CheckLevelCompletion(  )
  353.     UpdateGameMusic()
  354.     -- This is the intro, where you check for level 
  355.     if( levelRoutine ) then    
  356.         local con, error = coroutine.resume( levelRoutine )
  357.  
  358.         -- Start the Level Sequence:
  359.         if( con == false and GameState == InLevel ) then    
  360.             G.Mes( error )
  361.             levelRoutine = coroutine.create( LevelSequence )
  362.         end    
  363.     end    
  364. end
  365.  
  366. levelRoutine = coroutine.create(LevelIntro);
  367.  
  368. GMain["LevelUpdate"] = LevelUpdate;
  369.